home *** CD-ROM | disk | FTP | other *** search
/ Giga Games 1 / Giga Games.iso / net / go / prog / nextgo23.taz / nextgo23 / NeXTGo / exambord.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-02-09  |  1.6 KB  |  72 lines

  1. #include "comment.header"
  2.  
  3. #define EMPTY 0
  4. #define BLACKSTONE 2
  5.  
  6. extern unsigned char p[19][19], l[19][19];
  7. extern int MAXX, MAXY;
  8. extern int currentStone, opposingStone, whiteCaptured, blackCaptured;
  9. extern int whiteCapturedKoI, whiteCapturedKoJ, blackCapturedKoI, blackCapturedKoJ;
  10. extern void eval(int color);
  11.  
  12. void examboard(int color)
  13.      /* examine pieces */
  14. {
  15.   int i, j, n;
  16.  
  17.   for (i = 0; i < MAXX; i++)
  18.     for (j = 0; j < MAXY; j++)
  19.       if (p[i][j] > 2)
  20.     return;
  21.   
  22.   /* find liberty of each piece */
  23.   eval(color);
  24.   
  25.   /* initialize piece captured */
  26.   if (color == BLACKSTONE)
  27.     {
  28.       blackCapturedKoI = -1;
  29.       blackCapturedKoJ = -1;
  30.     }
  31.   else
  32.     {
  33.       whiteCapturedKoI = -1;
  34.       whiteCapturedKoJ = -1;
  35.     }
  36.   n = 0; /* The number of captures this move for Ko purposes */
  37.   
  38.   /* remove all piece of zero liberty */
  39.   for (i = 0; i < MAXX; i++)
  40.     for (j = 0; j < MAXY; j++)
  41.       if ((p[i][j] == color) && (l[i][j] == 0))
  42.     {
  43.       p[i][j] = EMPTY;
  44.       /* record piece captured */
  45.       if (color == BLACKSTONE)
  46.         {
  47.           blackCapturedKoI = i;
  48.           blackCapturedKoJ = j;
  49.           ++blackCaptured;
  50.         }
  51.       else
  52.         {
  53.           whiteCapturedKoI = i;
  54.           whiteCapturedKoJ = j;
  55.           ++whiteCaptured;
  56.         }
  57.       ++n;  /* increment number of captures on this move */
  58.     }
  59.   /* reset to -1 if more than one stone captured since  no Ko possible */
  60.   if ((color == BLACKSTONE) && (n > 1))
  61.     {
  62.       blackCapturedKoI = -1;
  63.       blackCapturedKoJ = -1;
  64.     }
  65.   else if ( n > 1 )
  66.     {
  67.       whiteCapturedKoI = -1;
  68.       whiteCapturedKoJ = -1;
  69.     }
  70. }  /* end examboard */
  71.  
  72.